function getStyle(oEle, attr) {
    if (window.getComputedStyle) {
        return window.getComputedStyle(oEle, null)[attr];
    }
    return oEle.currentStyle[attr];
}

function animate(oEle, json, callback) {
    //清除之前的定时器
    clearInterval(oEle.timer)
    //开启新的定时器
    oEle.timer = setInterval(function () {
        var attr;//属性
        var target;//目标值
        var current;//当前值
        var flag = true;
        for (var key in json) {
            if (key == "opacity") {
                attr = key;
                target = json[key] * 100;
                current = getStyle(oEle, attr) * 100;
            } else {
                attr = key;
                target = parseInt(json[key]);//防止传入参数带有px单位{left:"400px"}
                current = parseInt(getStyle(oEle,attr));
            }
            //步长=（目标值-当前值）/10
            var step = (target - current) / 10;
            step = step > 0 ? Math.ceil(step) : Math.floor(step);
            if (key == "opacity") {
                oEle.style.opacity = (current + step) / 100;
            } else if (key == "zIndex") {
                oEle.style.zIndex = target;
            } else {
                //新的位置=当前位置+步长
                oEle.style[attr] = current + step + "px"
            }
            //如果当前值不等于目标值，说明还没有到指定的地方
            if (current != target) {
                flag = false;//状态改为false，不清除定时器
            }
        }
        if (flag == true) {
            clearInterval(oEle.timer)
            if (typeof (callback) == "function") {
                callback();
            }
        }

    }, 40)
}